Fix overflow when using Long.MAX_VALUE as leeway#723
Fix overflow when using Long.MAX_VALUE as leeway#723jmerle wants to merge 2 commits intoauth0:masterfrom
Conversation
|
Hi @jmerle, Thank you for the detailed report and for putting creating a fix. You’re absolutely right that passing very large leeway values can lead to overflow in Instant arithmetic, and that’s something we should handle more gracefully. That said, using Regarding the fix, silently clamping the value changes semantics without making it visible to the caller. We’d prefer to either fail fast on invalid input or define a clear upper bound. We’re going to close this for now, but if you’d like to revisit with an approach that validates input and fails explicitly, we’d be happy to take another look. Appreciate the contribution, Thank you. |
Changes
Recently I tried to set the leeway of the JWT verifier to
Long.MAX_VALUEto do some local debugging where the token being expired didn't matter. Unfortunately the verifier crashed with a long overflow when I ran it. The alternative was to set the leeway to a large, but not too large value. Nonetheless, this PR fixes the overflow as I believe it to be a bug.Previous exception on the new
shouldValidateExpiresAtWithMaxLeeway:Previous exception on the new
shouldValidateNotBeforeWithMaxLeeway:References
N/A
Testing
Please describe how this can be tested by reviewers. Be specific about anything not tested and reasons why. If this library has unit and/or integration testing, tests should be added for new functionality and existing tests should complete without errors.
Checklist